﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MaLu.Common;
using MaLu.BusiLogic;
using System.Xml;
using MaLu.Framework.Common;

namespace MaluJg.web.ProjectFund
{
    public partial class item2 : ProjectPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }
        private void BindData()
        {
            string projectname = string.Empty;
            string content = BLProject.GetProjectItem(Provider, ProjectID, "item2.aspx", ref projectname);
            if (content != string.Empty)
            {
                XmlDocument document = new XmlDocument();
                document.LoadXml(content);
                XmlElement xe = document.SelectSingleNode("//招标单位") as XmlElement;
                tbZhaoBiaoDept.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//编号") as XmlElement;
                tbBianHao.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//工程名称") as XmlElement;
                tbProjectName.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//建设地点") as XmlElement;
                tbPlace.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//投资规模") as XmlElement;
                tbTouzhi.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//结构形式") as XmlElement;
                tbJieGou.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//建筑面积") as XmlElement;
                tbSquares.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//层数") as XmlElement;
                tbLevels.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//招标代理单位") as XmlElement;
                tbZhaoBiaoDaili.Text = Util.ReturnXml(xe.InnerText);
               
                xe = document.SelectSingleNode("//联系人") as XmlElement;
                tbContact.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//联系电话") as XmlElement;
                tbPhone.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//报名时间") as XmlElement;
                tbBaoMDate.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//报名网址") as XmlElement;
                tbSite.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//报名地址") as XmlElement;
                tbBaoMPlace.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//招标单位经办人签字") as XmlElement;
                tbZhaoBiaoJingBan.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//发布单位") as XmlElement;
                tbFaBu.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//经办人签字") as XmlElement;
                tbQianZi.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//日期") as XmlElement;
                tbDate.Text = Util.ReturnXml(xe.InnerText);
               

            }
        }

        private string FillContent()
        {
            string template = BLProject.GetTemplate(Provider, "item2.aspx");
            if (template != string.Empty)
            {

                XmlDocument document = new XmlDocument();
                document.LoadXml(template);
                XmlElement xe = document.SelectSingleNode("//招标单位") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbZhaoBiaoDept.Text.Trim());
                xe = document.SelectSingleNode("//编号") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbBianHao.Text.Trim());
                xe = document.SelectSingleNode("//工程名称") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbProjectName.Text.Trim());
                xe = document.SelectSingleNode("//建设地点") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbPlace.Text.Trim());
                xe = document.SelectSingleNode("//投资规模") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbTouzhi.Text.Trim());
                xe = document.SelectSingleNode("//结构形式") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbJieGou.Text.Trim());
                xe = document.SelectSingleNode("//建筑面积") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbSquares.Text.Trim());
                xe = document.SelectSingleNode("//层数") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbLevels.Text.Trim());
                xe = document.SelectSingleNode("//招标单位2") as XmlElement;
                xe.InnerText = "马陆镇城市规划建设管理办公室";
                xe = document.SelectSingleNode("//招标代理单位") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbZhaoBiaoDaili.Text.Trim());
                xe = document.SelectSingleNode("//报名条件") as XmlElement;
                xe.InnerText = "工程施工总承包三级资质及以上";
                xe = document.SelectSingleNode("//联系人") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbContact.Text.Trim());
                xe = document.SelectSingleNode("//联系电话") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbPhone.Text.Trim());
                xe = document.SelectSingleNode("//报名时间") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbBaoMDate.Text.Trim());
                xe = document.SelectSingleNode("//报名网址") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbSite.Text.Trim());
                xe = document.SelectSingleNode("//报名地址") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbBaoMPlace.Text.Trim());
                xe = document.SelectSingleNode("//招标单位经办人签字") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbZhaoBiaoJingBan.Text.Trim());
                xe = document.SelectSingleNode("//发布单位") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbFaBu.Text.Trim());
                xe = document.SelectSingleNode("//经办人签字") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbQianZi.Text.Trim());
                xe = document.SelectSingleNode("//日期") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbDate.Text.Trim());
                

                return document.OuterXml;
            }
            else
                return string.Empty;

        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            BLProject.SaveProjectItem(Provider, ProjectID, "item2.aspx", FillContent());


            string msg = "已保存!";

            string script = "<script>alert('" + msg + "');</script>";
            ClientScript.RegisterStartupScript(this.GetType(), "Close", script);


        }
    }
}
